/* GUI CONVERTED from rcrp09a.p (converter v1.76) Fri May  3 13:21:52 2002 */
/* rcrp09a.p - Release Management Customer Schedules                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.12.2.6 $                                                         */
/*V8:ConvertMode=Report                                                 */
/* REVISION: 7.3    LAST MODIFIED: 10/06/92           BY: WUG *G462*          */
/* REVISION: 7.3    LAST MODIFIED: 09/29/93           BY: WUG *GG02*          */
/* REVISION: 7.3    LAST MODIFIED: 04/21/94           BY: WUG *GJ50*          */
/* REVISION: 7.3    LAST MODIFIED: 07/15/94           BY: WUG *GK76*          */
/* REVISION: 7.3    LAST MODIFIED: 07/23/96           BY: *G29C* Ajit Deodhar */
/* REVISION: 8.6    LAST MODIFIED: 09/20/96           BY: TSI *K005*          */
/* REVISION: 8.6    LAST MODIFIED: 06/11/97           BY: *J1SX* Aruna Patil  */
/* REVISION: 8.6    LAST MODIFIED: 06/20/97           BY: *H19T* Seema Varma  */
/* REVISION: 8.6    LAST MODIFIED: 08/08/97           BY: *J1YQ* Suresh Nayak */
/* REVISION: 8.6    LAST MODIFIED: 10/07/97           BY: bvm  *K0KW*         */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 10/29/99   BY: *L0KS* Santosh Rao        */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */
/* REVISION: 9.1      LAST MODIFIED: 09/04/00   BY: *N0RB* BalbeerS Rajput    */
/* REVISION: 9.1      LAST MODIFIED: 11/22/00   BY: *J3QG* Kirti Desai        */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.12.2.5     BY: Anitha Gopal       DATE: 11/11/01  ECO: *N15Y*  */
/* $Revision: 1.12.2.6 $    BY: Katie Hilbert      DATE: 04/15/02  ECO: *P03J*   */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/** TO REMOVE ORACLE ERROR : DIVISOR IS EQUAL TO ZERO *         */

/* INTRADAY SHIPPING REPORT SUBPROGRAM */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdeclre.i}
{gplabel.i}

{wbrp02.i}

{rcrpvar.i "shared"}
define shared variable due_dt          as date no-undo.
define shared variable include_pastdue like mfc_logical no-undo.

define buffer custad for ad_mstr.
define buffer shipad for ad_mstr.
define buffer dockad for ad_mstr.

define variable net_req            like schd_upd_qty
   column-label "Past Due Net Req Qty!Net Required Qty".
define variable i                  as integer no-undo.
define variable prior_net_req      like schd_upd_qty.
define variable prior_part         as character no-undo.
define variable prior_contr        as character no-undo.
define variable l_prior_cum_demand as character
                                   format "x(20)" no-undo.
define variable l_part             like sod_part format "x(30)" no-undo.
define variable ponbr              like sod_contr_id format "x(22)" no-undo.
define variable disp-net           like sch_pcr_qty no-undo
   column-label "Prior Requirements!Std Pack Qty".
FORM /*GUI*/  with STREAM-IO /*GUI*/  frame heading width 80.

l_prior_cum_demand = dynamic-function('getTermLabelFillCentered' in h-label,
   input "PRIOR_CUM_DEMAND",
   input 20, input '*').

for each scx_ref
   fields(scx_line scx_order scx_part scx_po scx_shipfrom scx_shipto
          scx_type scx_custref scx_modelyr)
   where scx_type      = 1
     and scx_shipfrom  >= shipfrom_from
     and scx_shipfrom  <= shipfrom_to
     and scx_shipto    >= shipto_from
     and scx_shipto    <= shipto_to
     and scx_part      >= part_from
     and scx_part      <= part_to
     and scx_po        >= po_from
     and scx_po        <= po_to
     and scx_custref   >= custref_from
     and scx_custref   <= custref_to
     and scx_modelyr   >= modelyr_from
     and scx_modelyr   <= modelyr_to
     and scx_order     >= order_from
     and scx_order     <= order_to
   no-lock,

   each sod_det
   fields(sod_cmtindx  sod_contr_id sod_cum_qty sod_curr_rlse_id
          sod_custpart sod_dock     sod_line    sod_nbr
          sod_ord_mult sod_part     sod_pkg_code)
   where sod_nbr   = scx_order
     and sod_line  = scx_line
     and sod_dock  >= dock_from
     and sod_dock  <= dock_to
   no-lock,

   each so_mstr
   fields(so_cmtindx so_cum_acct so_cust so_nbr so_ship_cmplt)
   where so_nbr    = sod_nbr
     and so_cust  >= cust_from
     and so_cust  <= cust_to
   no-lock,

   each sch_mstr
   fields(sch_cmtindx sch_line sch_nbr sch_pcr_qty
          sch_rlse_id sch_type)
   where sch_type     = 3
     and sch_nbr      = sod_nbr
     and sch_line     = sod_line
     and sch_rlse_id  = sod_curr_rlse_id[3]

   no-lock
   break by scx_shipfrom
         by so_cust
         by scx_shipto
         by scx_order
         by sod_dock:

   if (not can-find (first schd_det
      where schd_type      = sch_type
        and schd_nbr       = sch_nbr
        and schd_line      = sch_line
        and schd_rlse_id   = sch_rlse_id))
        and sod_cum_qty[1] < sch_pcr_qty
   then do with frame f_detail:

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame f_detail:handle).

      for first si_mstr
         fields(si_desc si_site)
         where si_site = scx_shipfrom
         no-lock:
      end. /* FOR FIRST si_mstr */

      for first custad
         where custad.ad_addr = so_cust
         no-lock:
      end. /* FOR FIRST custad */

      for first shipad
         where shipad.ad_addr = scx_shipto
         no-lock:
      end. /* FOR FIRST shipad */

      for first dockad
         where dockad.ad_addr = sod_dock
         no-lock:
      end. /* FOR FIRST dockad */

      display
         skip(1)
         getTermLabelRtColon("SHIP-FROM",10) to 10 format "x(10)"
         si_site
         si_desc
         scx_order
         scx_line
         getTermLabelRtColon("CUSTOMER",10)  to 10 format "x(10)"
         so_cust
         if available custad
         then
            custad.ad_name
         else
            "" @ custad.ad_name
         skip
         getTermLabelRtColon("SHIP-TO",10)  to 10 format "x(10)"
         scx_shipto
         if available shipad
         then
            shipad.ad_name
         else
            "" @ shipad.ad_name
         skip
         getTermLabelRtColon("DOCK",10)  to 10 format "x(10)"
         sod_dock
         if available dockad
         then
            dockad.ad_name
         else
            "" @ dockad.ad_name
         getTermLabelRtColon("DATE",10)  to 10 format "x(10)"
         l_prior_cum_demand
      with frame f_heading page-top width 132 no-box
      no-labels STREAM-IO /*GUI*/ .

      display
         sod_part     @ l_part
         sod_contr_id @ ponbr
         (sch_pcr_qty - sod_cum_qty[1]) @ disp-net
         sod_pkg_code format "x(18)" column-label "Container Item"
      with frame f_detail width 132 no-box STREAM-IO /*GUI*/ .

      hide frame f_heading.
      hide frame f_detail.

   end. /* IF (not can-find (first schd_det...  */

   for each schd_det
      fields(schd_cmtindx   schd_cum_qty  schd_date
             schd_discr_qty schd_line     schd_nbr  schd_reference
             schd_rlse_id   schd_ship_qty schd_time schd_type)
      where schd_type     = sch_type
        and schd_nbr      = sch_nbr
        and schd_line     = sch_line
        and schd_rlse_id  = sch_rlse_id
        and (
             (not include_pastdue and schd_date = due_dt)
            or
             (include_pastdue and schd_date <= due_dt)
            )
        /* CUM/DISCRETE FILTER */
        and (
             (so_cum_acct and schd_cum_qty > sod_cum_qty[1])
            or
             (not so_cum_acct)
            )
      no-lock
      break
         by schd_date
         by schd_time
         by schd_reference
         by sod_part
         by sod_contr_id
         by scx_custref
         by scx_modelyr with frame f-a:

      /* SET EXTERNAL LABELS */
      setFrameLabels(frame f-a:handle).

      if schd_discr_qty <> 0
         and (schd_ship_qty / schd_discr_qty * 100 <
             (if so_ship_cmplt = 0
              then
                 100
              else
                 so_ship_cmplt))
      then do:

         if first-of(schd_reference)
         then do:

            for first si_mstr
               fields(si_desc si_site)
               where si_site = scx_shipfrom
               no-lock:
            end. /* FOR FIRST si_mstr */

            for first custad
               where custad.ad_addr = so_cust
               no-lock:
            end. /* FOR FIRST custad */

            for first shipad
               where shipad.ad_addr = scx_shipto
               no-lock:
            end. /* FOR FIRST shipad */

            for first dockad
               where dockad.ad_addr = sod_dock
               no-lock:
            end. /* FOR FIRST dockad */

            display
               skip(1)
               getTermLabelRtColon("SHIP-FROM",10) to 10 format "x(10)"
               si_site
               si_desc
               scx_order
               scx_line
               getTermLabelRtColon("CUSTOMER",10)  to 10 format "x(10)"
               so_cust
               if available custad
               then
                  custad.ad_name
               else
                  "" @ custad.ad_name
               skip
               getTermLabelRtColon("SHIP-TO",10)  to 10 format "x(10)"
               scx_shipto
               if available shipad
               then
                  shipad.ad_name
               else
                  "" @ shipad.ad_name
               skip
               getTermLabelRtColon("DOCK",10)  to 10 format "x(10)"
               sod_dock
               if available dockad
               then
                  dockad.ad_name
               else
                  "" @ dockad.ad_name
               getTermLabelRtColon("DATE",10)  to 10 format "x(10)"
               schd_date
               getTermLabelRtColon("TIME",10)  to 10 format "x(10)"
               schd_time
               getTermLabelRtColon("REFERENCE",10)  to 10 format "x(10)"
               schd_reference
               skip(1)
            with frame heading page-top width 132 no-box no-labels STREAM-IO /*GUI*/ .

            {gpcmtprt.i &type=PA &id=so_cmtindx &pos=3}
            {gpcmtprt.i &type=PA &id=sod_cmtindx &pos=3 &command="down 1."}
            {gpcmtprt.i &type=PA &id=sch_cmtindx &pos=3 &command="down 1."}

            assign
               prior_part  = ""
               prior_contr = "".
         end. /* IF FIRST-OF(schd_reference) */


         /* CALCULATE FOR CUM/DISCRETE */
         if so_cum_acct
         then
            assign
               net_req       = max(min(schd_discr_qty,
                                       schd_cum_qty - sod_cum_qty[1]),0)
               prior_net_req = max(schd_cum_qty -
                                   (sod_cum_qty[1] + net_req),0).
         else
            assign
               prior_net_req = if sod_part <> prior_part
                                  or sod_contr_id <> prior_contr
                               then
                                  0
                               else
                                  prior_net_req + net_req
               prior_part    = sod_part
               prior_contr   = sod_contr_id
               net_req       = schd_discr_qty - schd_ship_qty.

         display
            sod_part           format "x(30)" column-label "Item Number!Customer Ref"
            sod_contr_id       format "x(22)" column-label "PO Number!Model Year"
            schd_discr_qty     column-label "Discrete Qty!Std Pack Qty"
            prior_net_req @ net_req
            sod_pkg_code       format "x(18)" column-label "Container Item"
         with width 132 no-box STREAM-IO /*GUI*/ .

         down 1.

         display
            scx_custref @ sod_part
            scx_modelyr @ sod_contr_id
            sod_ord_mult when (sod_ord_mult > 1)  @ schd_discr_qty
            net_req
            sod_custpart @ sod_part WITH STREAM-IO /*GUI*/ .

         down 1.

         {gpcmtprt.i &type=PA &id=schd_cmtindx &pos=3 &command="down 1."}

         if last-of(schd_reference)
         then do:
            hide frame heading.
            page.
         end. /* IF LAST-OF(schd_reference) */

      end. /* IF SCHD_DISCR_QTY <> 0 AND .. */

   end. /* FOR EACH schd_det */

   
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


end. /* FOR EACH scx_ref */
{wbrp04.i}
